// pages/expressbox/expresslist/expresslist.js
import {
  getExpressList, 
} from '../../../utils/networkRequest.js'
import {
  errorMsg
} from '../../../utils/tool.js'
Page({


  /**
   * 页面的初始数据
   */
  data: {
    dataList: []
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onShow: function() {
    let self = this;
    getExpressList("", (r) => {
      if (r.code == 0) {
        self.setData({
          dataList: r.data
        })
      } else {
        errorMsg(r.message);
      }
    })
  },
  goExpressAdd: function() {
    wx.navigateTo({
      url: '../expressadd/expressadd',
    })
  },
 
  //选择快递
  checkExpress: function(e) {
    let self = this;
    let id = e.currentTarget.dataset.id
    getExpressList(id, (r) => {
      if (r.code == 0) {
        self.setData({
          dataList: r.data
        })
        errorMsg("切换成功");
      } else {
        errorMsg(r.message);
      }
    })
  },
  //修改快递公司
  onEdit:function(e){
    let item = e.currentTarget.dataset.item;
    wx.navigateTo({
      url: '../expressadd/expressadd?isEdit=true&item=' + JSON.stringify(item),
    })
  }
})